$().ready(function() {
});

$.validator.setDefaults({
	submitHandler : function() {
		importInfo();
	}
});

function importInfo() {
	$.ajax({
		cache : true,
		type : "POST",
		url : "/pro/instock/importInfo",
		data : $('#signupForm').serialize(),// 你的formid
		async : false,
		error : function(request) {
			parent.layer.alert("Connection error");
		},
		success : function(data) {
			if (data.code == 0) {
				parent.layer.msg("操作成功");
				parent.reLoad();
				var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
				parent.layer.close(index);
			} else {
				parent.layer.alert(data.msg)
			}

		}
	});
}

//根据SKU查询商品基本信息
function downloadTemplate() {
	$.ajax({
		url :"/pro/instock/downloadTemplate",
		data: null,
		type:"get",
		dataType:"json",
		success : function(data) {
		}
	});
}
//上传Excel
layui.use('upload', function(){
	var upload = layui.upload;
	//执行实例
	var uploadInst = upload.render({
		elem: '#upLoad' //绑定元素
		,url: '/pro/instock/importInfo'
		,accept: 'file' //普通文件
		,exts: 'xls|xlsx' //允许上传的文件后缀//上传接口
		,multiple: true
		,done: function(res){
			parent.layer.msg("上传成功");
			parent.reLoad();
			var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
			parent.layer.close(index);
		}
		,error: function(){
			//请求异常回调
		}
	});
})
